package com.youyi.yyviewsdklibrary.Dialog;

import android.app.AppOpsManager;
import android.app.Application;
import android.app.Dialog;
import android.arch.lifecycle.Lifecycle;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PointF;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.provider.Settings;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator;
import com.youyi.yyviewsdklibrary.Dialog.core.BasePopupView;
import com.youyi.yyviewsdklibrary.Dialog.core.BottomPopupView;
import com.youyi.yyviewsdklibrary.Dialog.core.CenterPopupView;
import com.youyi.yyviewsdklibrary.Dialog.core.ImageViewerPopupView;
import com.youyi.yyviewsdklibrary.Dialog.core.PopupInfo;
import com.youyi.yyviewsdklibrary.Dialog.core.VerAttachPopupView;
import com.youyi.yyviewsdklibrary.Dialog.core.XDialog;
import com.youyi.yyviewsdklibrary.Dialog.enums.PopupAnimation;
import com.youyi.yyviewsdklibrary.Dialog.enums.PopupPosition;
import com.youyi.yyviewsdklibrary.Dialog.impl.AttachListPopupView;
import com.youyi.yyviewsdklibrary.Dialog.impl.BottomListPopupView;
import com.youyi.yyviewsdklibrary.Dialog.impl.CenterListPopupView;
import com.youyi.yyviewsdklibrary.Dialog.impl.ConfirmPopupView;
import com.youyi.yyviewsdklibrary.Dialog.impl.InputConfirmPopupView;
import com.youyi.yyviewsdklibrary.Dialog.impl.LoadingPopupView;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnCancelListener;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnConfirmListener;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnImageViewerLongPressListener;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnInputConfirmListener;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnSelectListener;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnSrcViewUpdateListener;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnViewBack;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.XPopupCallback;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.XPopupImageLoader;
import com.youyi.yyviewsdklibrary.Dialog.util.XPermission;
import com.youyi.yyviewsdklibrary.Dialog.util.XPopupUtils;
import com.lkx.liandianqinew.R;
import com.youyi.yyviewsdklibrary.YYSDK;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class XPopup {
    private static int animationDuration = 300;
    private static Context context;
    public static int isLightNavigationBar = 0;
    public static int isLightStatusBar = 0;
    public static PointF longClickPoint = null;
    private static int navigationBarColor = 0;
    private static int primaryColor = Color.parseColor("#121212");
    private static int shadowBgColor = Color.parseColor("#7F000000");
    private static int statusBarBgColor = Color.parseColor("#55000000");

    public enum DirecEnum {
        CENTER,
        BOTTOM
    }

    private XPopup() {
    }

    public static void showDefineAttachBottom(Context context2, View view, boolean z, int i, OnViewBack onViewBack) {
        if (context2 instanceof Application) {
            YYSDK.toast(YYSDK.YToastEnum.err, "不支持系统级别弹出！");
            return;
        }
        new Builder(context2).isDestroyOnDismiss(true).dismissOnTouchOutside(Boolean.valueOf(z)).hasShadowBg(false).isViewMode(true).atView(view).asCustom(new VerAttachPopupView(context2, i, onViewBack)).show();
    }

    public static void showDefine(Context context2, DirecEnum direcEnum, boolean z, int i, OnViewBack onViewBack) {
        boolean z2 = context2 instanceof Application;
        if (!z2) {
            BasePopupView basePopupView = null;
            int i2 = direcEnum.ordinal();
            if (i2 == 1) {
                basePopupView = new CenterPopupView(context2, i, onViewBack);
            } else if (i2 == 2) {
                basePopupView = new BottomPopupView(context2, i, onViewBack);
            }
            new Builder(context2).moveUpToKeyboard(false).dismissOnTouchOutside(Boolean.valueOf(z)).enableDrag(false).enableShowWhenAppBackground(z2).isDestroyOnDismiss(true).asCustom(basePopupView).show();
        } else if (!checkOp(context2)) {
            openOp(context2);
        } else {
            int i3 = direcEnum.ordinal();
            if (i3 == 1) {
                createBottomSysDailog(context2, true, i, onViewBack).setCancelable(z);
            } else if (i3 == 2) {
                createBottomSysDailog(context2, false, i, onViewBack).setCancelable(z);
            }
        }
    }

    public static void showDefineNoFalse(Context context2, DirecEnum direcEnum, boolean z, int i, OnViewBack onViewBack) {
        boolean z2 = context2 instanceof Application;
        if (!z2) {
            BasePopupView basePopupView = null;
            int i2 = direcEnum.ordinal();
            if (i2 == 1) {
                basePopupView = new CenterPopupView(context2, i, onViewBack);
            } else if (i2 == 2) {
                basePopupView = new BottomPopupView(context2, i, onViewBack);
            }
            new Builder(context2).moveUpToKeyboard(false).dismissOnTouchOutside(Boolean.valueOf(z)).enableDrag(false).enableShowWhenAppBackground(z2).isDestroyOnDismiss(true).asCustom(basePopupView).show();
        } else if (!checkOp(context2)) {
            openOp(context2);
        } else {
            int i3 = direcEnum.ordinal();
            if (i3 == 1) {
                createBottomSysDailogNoFalse(context2, true, i, onViewBack).setCancelable(z);
            } else if (i3 == 2) {
                createBottomSysDailogNoFalse(context2, false, i, onViewBack).setCancelable(z);
            }
        }
    }

    public static Dialog createBottomSysDailog(Context context2, boolean z, int i, OnViewBack onViewBack) {
        Dialog dialog = new Dialog(context2, R.style.ViewActionSheetDialogStyle);
        if (!checkOp(context2)) {
            openOp(context2);
        }
        try {
            dialog.requestWindowFeature(1);
            View inflate = View.inflate(context2, i, null);
            if (onViewBack != null) {
                onViewBack.result(new XDialog(null, dialog), inflate);
            }
            dialog.setContentView(inflate);
            Window window = dialog.getWindow();
            WindowManager.LayoutParams attributes = window.getAttributes();
            if (z) {
                window.setGravity(17);
            } else {
                window.setGravity(80);
            }
            if (Build.VERSION.SDK_INT >= 26) {
                window.setType(2038);
            } else {
                window.setType(2003);
            }
            attributes.width = -1;
            attributes.height = -2;
            window.setAttributes(attributes);
            dialog.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dialog;
    }

    public static Dialog createBottomSysDailogNoFalse(Context context2, boolean z, int i, OnViewBack onViewBack) {
        Dialog dialog = new Dialog(context2, R.style.ViewActionSheetDialogStyleNoFalse);
        if (!checkOp(context2)) {
            openOp(context2);
        }
        try {
            dialog.requestWindowFeature(1);
            View inflate = View.inflate(context2, i, null);
            if (onViewBack != null) {
                onViewBack.result(new XDialog(null, dialog), inflate);
            }
            dialog.setContentView(inflate);
            Window window = dialog.getWindow();
            WindowManager.LayoutParams attributes = window.getAttributes();
            if (z) {
                window.setGravity(17);
            } else {
                window.setGravity(80);
            }
            if (Build.VERSION.SDK_INT >= 26) {
                window.setType(2038);
            } else {
                window.setType(2003);
            }
            attributes.width = -1;
            attributes.height = -2;
            window.setAttributes(attributes);
            dialog.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dialog;
    }

    public static void setShadowBgColor(int i) {
        shadowBgColor = i;
    }

    public static int getShadowBgColor() {
        return shadowBgColor;
    }

    public static void setStatusBarBgColor(int i) {
        statusBarBgColor = i;
    }

    public static int getStatusBarBgColor() {
        return statusBarBgColor;
    }

    public static void setNavigationBarColor(int i) {
        navigationBarColor = i;
    }

    public static int getNavigationBarColor() {
        return navigationBarColor;
    }

    public static void setPrimaryColor(int i) {
        primaryColor = i;
    }

    public static int getPrimaryColor() {
        return primaryColor;
    }

    public static void setIsLightStatusBar(boolean z) {
        isLightStatusBar = z ? 1 : -1;
    }

    public static void setIsLightNavigationBar(boolean z) {
        isLightNavigationBar = z ? 1 : -1;
    }

    public static void setAnimationDuration(int i) {
        if (i >= 0) {
            animationDuration = i;
        }
    }

    public static int getAnimationDuration() {
        return animationDuration;
    }

    public static void fixLongClick(View view) {
        view.setOnTouchListener(new View.OnTouchListener() {
            /* class com.youyi.yyviewsdklibrary.Dialog.XPopup.AnonymousClass1 */

            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (motionEvent.getAction() == 0) {
                    XPopup.longClickPoint = new PointF(motionEvent.getRawX(), motionEvent.getRawY());
                }
                if ("xpopup".equals(view.getTag()) && motionEvent.getAction() == 2) {
                    view.getParent().requestDisallowInterceptTouchEvent(true);
                }
                if (motionEvent.getAction() == 1) {
                    view.getParent().requestDisallowInterceptTouchEvent(false);
                    view.setTag(null);
                }
                return false;
            }
        });
        view.setTag("xpopup");
    }

    public static class Builder {
        private Context context;
        private final PopupInfo popupInfo = new PopupInfo();

        public Builder(Context context2) {
            this.context = context2;
        }

        public Builder dismissOnBackPressed(Boolean bool) {
            this.popupInfo.isDismissOnBackPressed = bool;
            return this;
        }

        public Builder dismissOnTouchOutside(Boolean bool) {
            this.popupInfo.isDismissOnTouchOutside = bool;
            return this;
        }

        public Builder autoDismiss(Boolean bool) {
            this.popupInfo.autoDismiss = bool;
            return this;
        }

        public Builder hasShadowBg(Boolean bool) {
            this.popupInfo.hasShadowBg = bool;
            return this;
        }

        public Builder hasBlurBg(boolean z) {
            this.popupInfo.hasBlurBg = Boolean.valueOf(z);
            return this;
        }

        public Builder atView(View view) {
            this.popupInfo.atView = view;
            return this;
        }

        public Builder watchView(View view) {
            view.setOnTouchListener(new View.OnTouchListener() {
                /* class com.youyi.yyviewsdklibrary.Dialog.XPopup.Builder.AnonymousClass1 */

                public boolean onTouch(View view, MotionEvent motionEvent) {
                    if (motionEvent.getAction() != 0) {
                        return false;
                    }
                    Builder.this.popupInfo.touchPoint = new PointF(motionEvent.getRawX(), motionEvent.getRawY());
                    return false;
                }
            });
            return this;
        }

        public Builder popupAnimation(PopupAnimation popupAnimation) {
            this.popupInfo.popupAnimation = popupAnimation;
            return this;
        }

        public Builder customAnimator(PopupAnimator popupAnimator) {
            this.popupInfo.customAnimator = popupAnimator;
            return this;
        }

        public Builder popupHeight(int i) {
            this.popupInfo.popupHeight = i;
            return this;
        }

        public Builder popupWidth(int i) {
            this.popupInfo.popupWidth = i;
            return this;
        }

        public Builder maxWidth(int i) {
            this.popupInfo.maxWidth = i;
            return this;
        }

        public Builder maxHeight(int i) {
            this.popupInfo.maxHeight = i;
            return this;
        }

        public Builder autoOpenSoftInput(Boolean bool) {
            this.popupInfo.autoOpenSoftInput = bool;
            return this;
        }

        public Builder moveUpToKeyboard(Boolean bool) {
            this.popupInfo.isMoveUpToKeyboard = bool;
            return this;
        }

        public Builder popupPosition(PopupPosition popupPosition) {
            this.popupInfo.popupPosition = popupPosition;
            return this;
        }

        public Builder hasStatusBarShadow(boolean z) {
            this.popupInfo.hasStatusBarShadow = Boolean.valueOf(z);
            return this;
        }

        public Builder hasStatusBar(boolean z) {
            this.popupInfo.hasStatusBar = Boolean.valueOf(z);
            return this;
        }

        public Builder hasNavigationBar(boolean z) {
            this.popupInfo.hasNavigationBar = Boolean.valueOf(z);
            return this;
        }

        public Builder navigationBarColor(int i) {
            this.popupInfo.navigationBarColor = i;
            return this;
        }

        public Builder isLightNavigationBar(boolean z) {
            this.popupInfo.isLightNavigationBar = z ? 1 : -1;
            return this;
        }

        public Builder isLightStatusBar(boolean z) {
            this.popupInfo.isLightStatusBar = z ? 1 : -1;
            return this;
        }

        public Builder statusBarBgColor(int i) {
            this.popupInfo.statusBarBgColor = i;
            return this;
        }

        public Builder offsetX(int i) {
            this.popupInfo.offsetX = i;
            return this;
        }

        public Builder offsetY(int i) {
            this.popupInfo.offsetY = i;
            return this;
        }

        public Builder enableDrag(boolean z) {
            this.popupInfo.enableDrag = Boolean.valueOf(z);
            return this;
        }

        public Builder isCenterHorizontal(boolean z) {
            this.popupInfo.isCenterHorizontal = z;
            return this;
        }

        public Builder isRequestFocus(boolean z) {
            this.popupInfo.isRequestFocus = z;
            return this;
        }

        public Builder autoFocusEditText(boolean z) {
            this.popupInfo.autoFocusEditText = z;
            return this;
        }

        public Builder isDarkTheme(boolean z) {
            this.popupInfo.isDarkTheme = z;
            return this;
        }

        public Builder isClickThrough(boolean z) {
            this.popupInfo.isClickThrough = z;
            return this;
        }

        public Builder isTouchThrough(boolean z) {
            this.popupInfo.isTouchThrough = z;
            return this;
        }

        public Builder enableShowWhenAppBackground(boolean z) {
            this.popupInfo.enableShowWhenAppBackground = z;
            return this;
        }

        public Builder isThreeDrag(boolean z) {
            this.popupInfo.isThreeDrag = z;
            return this;
        }

        public Builder isDestroyOnDismiss(boolean z) {
            this.popupInfo.isDestroyOnDismiss = z;
            return this;
        }

        public Builder borderRadius(float f) {
            this.popupInfo.borderRadius = f;
            return this;
        }

        public Builder positionByWindowCenter(boolean z) {
            this.popupInfo.positionByWindowCenter = z;
            return this;
        }

        public Builder isViewMode(boolean z) {
            this.popupInfo.isViewMode = z;
            return this;
        }

        public Builder shadowBgColor(int i) {
            this.popupInfo.shadowBgColor = i;
            return this;
        }

        public Builder animationDuration(int i) {
            this.popupInfo.animationDuration = i;
            return this;
        }

        public Builder keepScreenOn(boolean z) {
            this.popupInfo.keepScreenOn = z;
            return this;
        }

        public Builder notDismissWhenTouchInView(View view) {
            if (this.popupInfo.notDismissWhenTouchInArea == null) {
                this.popupInfo.notDismissWhenTouchInArea = new ArrayList<>();
            }
            this.popupInfo.notDismissWhenTouchInArea.add(XPopupUtils.getViewRect(view));
            return this;
        }

        public Builder customHostLifecycle(Lifecycle lifecycle) {
            this.popupInfo.hostLifecycle = lifecycle;
            return this;
        }

        public Builder setPopupCallback(XPopupCallback xPopupCallback) {
            this.popupInfo.xPopupCallback = xPopupCallback;
            return this;
        }

        public ConfirmPopupView asConfirm(CharSequence charSequence, CharSequence charSequence2, boolean z, CharSequence charSequence3, CharSequence charSequence4, OnConfirmListener onConfirmListener, OnCancelListener onCancelListener, boolean z2, int i) {
            ConfirmPopupView confirmPopupView = new ConfirmPopupView(this.context, z, i);
            confirmPopupView.setTitleContent(charSequence, charSequence2, null);
            confirmPopupView.setCancelText(charSequence3);
            confirmPopupView.setConfirmText(charSequence4);
            confirmPopupView.setListener(onConfirmListener, onCancelListener);
            confirmPopupView.isHideCancel = z2;
            confirmPopupView.popupInfo = this.popupInfo;
            return confirmPopupView;
        }

        public ConfirmPopupView asConfirm(CharSequence charSequence, CharSequence charSequence2, boolean z, CharSequence charSequence3, CharSequence charSequence4, OnConfirmListener onConfirmListener, OnCancelListener onCancelListener, boolean z2) {
            return asConfirm(charSequence, charSequence2, z, charSequence3, charSequence4, onConfirmListener, onCancelListener, z2, 0);
        }

        public InputConfirmPopupView asInputConfirm(CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, CharSequence charSequence4, OnInputConfirmListener onInputConfirmListener, OnCancelListener onCancelListener, int i) {
            InputConfirmPopupView inputConfirmPopupView = new InputConfirmPopupView(this.context, i);
            inputConfirmPopupView.setTitleContent(charSequence, charSequence2, charSequence4);
            inputConfirmPopupView.inputContent = charSequence3;
            inputConfirmPopupView.setListener(onInputConfirmListener, onCancelListener);
            inputConfirmPopupView.popupInfo = this.popupInfo;
            return inputConfirmPopupView;
        }

        public InputConfirmPopupView asInputConfirm(CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, CharSequence charSequence4, OnInputConfirmListener onInputConfirmListener) {
            return asInputConfirm(charSequence, charSequence2, charSequence3, charSequence4, onInputConfirmListener, null, 0);
        }

        public InputConfirmPopupView asInputConfirm(CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, OnInputConfirmListener onInputConfirmListener) {
            return asInputConfirm(charSequence, charSequence2, null, charSequence3, onInputConfirmListener, null, 0);
        }

        public InputConfirmPopupView asInputConfirm(CharSequence charSequence, CharSequence charSequence2, OnInputConfirmListener onInputConfirmListener) {
            return asInputConfirm(charSequence, charSequence2, null, null, onInputConfirmListener, null, 0);
        }

        public CenterListPopupView asCenterList(CharSequence charSequence, String[] strArr, int[] iArr, int i, OnSelectListener onSelectListener, int i2, int i3) {
            CenterListPopupView onSelectListener2 = new CenterListPopupView(this.context, i2, i3).setStringData(charSequence, strArr, iArr).setCheckedPosition(i).setOnSelectListener(onSelectListener);
            onSelectListener2.popupInfo = this.popupInfo;
            return onSelectListener2;
        }

        public CenterListPopupView asCenterList(CharSequence charSequence, String[] strArr, int[] iArr, int i, OnSelectListener onSelectListener) {
            return asCenterList(charSequence, strArr, iArr, i, onSelectListener, 0, 0);
        }

        public CenterListPopupView asCenterList(CharSequence charSequence, String[] strArr, OnSelectListener onSelectListener) {
            return asCenterList(charSequence, strArr, null, -1, onSelectListener);
        }

        public CenterListPopupView asCenterList(CharSequence charSequence, String[] strArr, int[] iArr, OnSelectListener onSelectListener) {
            return asCenterList(charSequence, strArr, iArr, -1, onSelectListener);
        }

        public LoadingPopupView asLoading(CharSequence charSequence, int i) {
            LoadingPopupView title = new LoadingPopupView(this.context, i).setTitle(charSequence);
            title.popupInfo = this.popupInfo;
            return title;
        }

        public LoadingPopupView asLoading(CharSequence charSequence) {
            return asLoading(charSequence, 0);
        }

        public LoadingPopupView asLoading() {
            return asLoading(null);
        }

        public BottomListPopupView asBottomList(CharSequence charSequence, String[] strArr, int[] iArr, int i, boolean z, OnSelectListener onSelectListener, int i2, int i3) {
            BottomListPopupView onSelectListener2 = new BottomListPopupView(this.context, i2, i3).setStringData(charSequence, strArr, iArr).setCheckedPosition(i).setOnSelectListener(onSelectListener);
            onSelectListener2.popupInfo = this.popupInfo;
            return onSelectListener2;
        }

        public BottomListPopupView asBottomList(CharSequence charSequence, String[] strArr, int[] iArr, int i, boolean z, OnSelectListener onSelectListener) {
            return asBottomList(charSequence, strArr, iArr, i, z, onSelectListener, 0, 0);
        }

        public BottomListPopupView asBottomList(CharSequence charSequence, String[] strArr, OnSelectListener onSelectListener) {
            return asBottomList(charSequence, strArr, null, -1, true, onSelectListener);
        }

        public BottomListPopupView asBottomList(CharSequence charSequence, String[] strArr, int[] iArr, OnSelectListener onSelectListener) {
            return asBottomList(charSequence, strArr, iArr, -1, true, onSelectListener);
        }

        public BottomListPopupView asBottomList(CharSequence charSequence, String[] strArr, int[] iArr, int i, OnSelectListener onSelectListener) {
            return asBottomList(charSequence, strArr, iArr, i, true, onSelectListener);
        }

        public BottomListPopupView asBottomList(CharSequence charSequence, String[] strArr, int[] iArr, boolean z, OnSelectListener onSelectListener) {
            return asBottomList(charSequence, strArr, iArr, -1, z, onSelectListener);
        }

        public AttachListPopupView asAttachList(String[] strArr, int[] iArr, OnSelectListener onSelectListener, int i, int i2, int i3) {
            AttachListPopupView onSelectListener2 = new AttachListPopupView(this.context, i, i2).setStringData(strArr, iArr).setContentGravity(i3).setOnSelectListener(onSelectListener);
            onSelectListener2.popupInfo = this.popupInfo;
            return onSelectListener2;
        }

        public AttachListPopupView asAttachList(String[] strArr, int[] iArr, OnSelectListener onSelectListener, int i, int i2) {
            return asAttachList(strArr, iArr, onSelectListener, i, i2, 17);
        }

        public AttachListPopupView asAttachList(String[] strArr, int[] iArr, OnSelectListener onSelectListener) {
            return asAttachList(strArr, iArr, onSelectListener, 0, 0, 17);
        }

        public ImageViewerPopupView asImageViewer(ImageView imageView, Object obj, boolean z, XPopupImageLoader xPopupImageLoader) {
            ImageViewerPopupView xPopupImageLoader2 = new ImageViewerPopupView(this.context).setSingleSrcView(imageView, obj).isShowSaveButton(z).setXPopupImageLoader(xPopupImageLoader);
            xPopupImageLoader2.popupInfo = this.popupInfo;
            return xPopupImageLoader2;
        }

        public ImageViewerPopupView asImageViewer(ImageView imageView, Object obj, boolean z, int i, int i2, int i3, boolean z2, int i4, XPopupImageLoader xPopupImageLoader, OnImageViewerLongPressListener onImageViewerLongPressListener) {
            ImageViewerPopupView longPressListener = new ImageViewerPopupView(this.context).setSingleSrcView(imageView, obj).isInfinite(z).setPlaceholderColor(i).setPlaceholderStrokeColor(i2).setPlaceholderRadius(i3).isShowSaveButton(z2).setBgColor(i4).setXPopupImageLoader(xPopupImageLoader).setLongPressListener(onImageViewerLongPressListener);
            longPressListener.popupInfo = this.popupInfo;
            return longPressListener;
        }

        public ImageViewerPopupView asImageViewer(ImageView imageView, int i, List<Object> list, OnSrcViewUpdateListener onSrcViewUpdateListener, XPopupImageLoader xPopupImageLoader) {
            return asImageViewer(imageView, i, list, false, true, -1, -1, -1, true, Color.rgb(32, 36, 46), onSrcViewUpdateListener, xPopupImageLoader, null);
        }

        public ImageViewerPopupView asImageViewer(ImageView imageView, int i, List<Object> list, boolean z, boolean z2, int i2, int i3, int i4, boolean z3, int i5, OnSrcViewUpdateListener onSrcViewUpdateListener, XPopupImageLoader xPopupImageLoader, OnImageViewerLongPressListener onImageViewerLongPressListener) {
            ImageViewerPopupView longPressListener = new ImageViewerPopupView(this.context).setSrcView(imageView, i).setImageUrls(list).isInfinite(z).isShowPlaceholder(z2).setPlaceholderColor(i2).setPlaceholderStrokeColor(i3).setPlaceholderRadius(i4).isShowSaveButton(z3).setBgColor(i5).setSrcViewUpdateListener(onSrcViewUpdateListener).setXPopupImageLoader(xPopupImageLoader).setLongPressListener(onImageViewerLongPressListener);
            longPressListener.popupInfo = this.popupInfo;
            return longPressListener;
        }

        public BasePopupView asCustom(BasePopupView basePopupView) {
            basePopupView.popupInfo = this.popupInfo;
            return basePopupView;
        }
    }

    public static void requestOverlayPermission(Context context2, XPermission.SimpleCallback simpleCallback) {
        if (Build.VERSION.SDK_INT >= 23) {
            XPermission.create(context2, new String[0]).requestDrawOverlays(simpleCallback);
        } else {
            simpleCallback.onGranted();
        }
    }

    public static boolean checkOp(Context context2) {
        if (Build.VERSION.SDK_INT >= 23) {
            return Settings.canDrawOverlays(context2);
        }
        boolean z = Build.VERSION.SDK_INT < 19;
        if (z || Build.VERSION.SDK_INT < 19) {
            return z;
        }
        if (((AppOpsManager) context2.getSystemService("appops")) == null) {
            return true;
        }
        try {
            Class<?> cls = Class.forName("android.content.Context");
            Field declaredField = cls.getDeclaredField("APP_OPS_SERVICE");
            declaredField.setAccessible(true);
            Object obj = declaredField.get(cls);
            if (!(obj instanceof String)) {
                return false;
            }
            Object invoke = cls.getMethod("getSystemService", String.class).invoke(context2, (String) obj);
            Class<?> cls2 = Class.forName("android.app.AppOpsManager");
            Field declaredField2 = cls2.getDeclaredField("MODE_ALLOWED");
            declaredField2.setAccessible(true);
            if (((Integer) cls2.getMethod("checkOp", Integer.TYPE, Integer.TYPE, String.class).invoke(invoke, 24, Integer.valueOf(Binder.getCallingUid()), context2.getPackageName())).intValue() == declaredField2.getInt(cls2)) {
                return true;
            }
            return false;
        } catch (Exception unused) {
            return false;
        }
    }

    public static void openOp(Context context2) {
        try {
            Intent intent = new Intent("android.settings.action.MANAGE_OVERLAY_PERMISSION");
            intent.setData(Uri.parse("package:" + context2.getPackageName()));
            if (context2 instanceof Application) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            }
            context2.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
